*Set Directories
global UOA ""
global data_out "$UOA/Processed_Data"
global data_in "$UOA/Raw Data"
global lookup "$UOA/Lookup Tables"
global plotdir "$UOA/Tables and Figures"
global Construction "$UOA/Sample Construction"
global Outcomes "$UOA/Outcomes"
global Analysis "$UOA/Analysis"
global Robust "$Analysis/Robustness"
global logs  "$UOA/Log"



set more off
*cd "$plotdir"

*Create Log
local file Master //EDIT

capture log close
log using "$logs/`file'_$S_DATE.log", replace

*Globals are used for the main specifications. 


global spec1 "i.age_bin race_white female junior_enlisted college married longevity afqt_p (ed_prescription = propensity), absorb(hym hd i.diag mos) cluster(provID)" 
global spec2 "i.age_bin race_white female junior_enlisted college married longevity afqt_p (ed_prescription = above) if inlist(quartile,1,4), absorb(hym hd i.diag mos) cluster(provID)" 

global spec_promotions1 "i.age_bin race_white female i.grade college married longevity afqt_p (ed_prescription = propensity), absorb(hym hd i.diag mos) cluster(provID)" 
global spec_promotions2 "i.age_bin race_white female i.grade college married longevity afqt_p (ed_prescription = above) if inlist(quartile,1,4), absorb(hym hd i.diag mos) cluster(provID)" 

 
*Construct Main Sample and Physician Propensities to Prescribe
 
do "01_Prescriptions.do"
do "02_Demographics.do"
do "03_Construction.do"
do "04_Physician_Propensity.do"


*Construct Outcomes

foreach outcome in 05_Drug_Tests 06_Promotions 07_APFT 08_Flags 09_Discharges 10_Clearances  11_Capability {

do "`outcome'.do"
clear
}

*Create Figure 

do "11_Figure_1.do"


*Build Regression Tables

do "12_Opioid_Use.do""
do "13_Promotions_Analysis.do"
do "14_APFT_Analysis.do"
do "15_Flags_Analysis.do"
do "16_Discharge_Analysis"



*Appendix 1*

do "17_Balance.do"
do "18_Balance_NoControls"
do "19_Presenting_Diagnosis.do"
do "20_Monotonicity.do" 
do "21_FLL.do"
do "22_Threshold.do"
do "23_Clearance.do"
do "24_Intensity.do"


*Appendix 2*

do "25_Sensitivity.do"
do "26_Capability.do"
do "27_Attrition.do"
do "28_Compliers.do"





